﻿namespace ApiTemplate.WebApi.Config
{
    /// <summary>
    /// 自定义JobFactory
    /// </summary>
    public class ExtendJobFactory : IJobFactory
    {
        private readonly ISchedulerTaskDAL _schedulerTaskDAL;
        private readonly ISchedulerTaskLogDAL _schedulerTaskLogDAL;

        /// <summary>
        /// 构造注入
        /// </summary>
        /// <param name="schedulerTaskDAL"></param>
        /// <param name="schedulerTaskLogDAL"></param>
        public ExtendJobFactory(ISchedulerTaskDAL schedulerTaskDAL, ISchedulerTaskLogDAL schedulerTaskLogDAL)
        {
            _schedulerTaskDAL = schedulerTaskDAL;
            _schedulerTaskLogDAL = schedulerTaskLogDAL;
        }

        /// <summary>
        /// 自定义创建Job
        /// </summary>
        /// <param name="bundle"></param>
        /// <param name="scheduler"></param>
        /// <returns></returns>
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            HttpJob httpJob = new(_schedulerTaskDAL, _schedulerTaskLogDAL);
            return httpJob;
        }

        /// <summary>
        /// 返回job？
        /// </summary>
        /// <param name="job"></param>
        public void ReturnJob(IJob job)
        {

        }
    }
}
